package com.sky.mapper;

import com.sky.entity.User;
import com.sky.vo.UserVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user where openid=#{openId}")
    User selectByOpenId(String openId);
    void insert(User user);

    /**
     * 根据id获取用户
     * @param id
     * @return
     */
    @Select("select * from user where id=#{id}")
    User selectById(Long id);

    /**
     * 获取用户日增长数据
     * @param begin
     * @param end
     * @return
     */
    List<UserVO> getUserAddition(LocalDate begin, LocalDate end);

    /**
     * 查询早于某个时间节点的用户数
     * @param latestTime
     * @return
     */
    @Select("select count(*) from user where DATE(create_time)<#{latestTime}")
    Long cntUserBefore(LocalDate latestTime);
}
